//
//  MainTabBarVC.swift
//  testsetting
//
//  Created by GAOMO on 2019/10/16.
//  Copyright © 2019 GAOMO. All rights reserved.
//

import UIKit

class MainTabBarVC: UITabBarController {

    var _backView:UIView? = nil
    var items:NSArray = []
    let nameArr = ["游戏","开服","礼包","我的"]
    let picArr = ["wode_moren","wode_morenselect","wode_morenselect","wode_morenselect"]
    let picSelectArr = ["gameSelected","ic_home_checked","giftSelected","mineSelected"]
    
    var navVCArr:[NSObject] = [NSObject]()
    var nav:UINavigationController = UINavigationController()
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
self.CreatTabBar()
        // Do any additional setup after loading the view.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */
        func CreatTabBar() {
            _backView = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 49))
            
            for M in 0..<nameArr.count {
                let mainVC = ViewController()
                
                nav = UINavigationController(rootViewController: mainVC)
                nav.tabBarItem.title = nameArr[M]
                nav.tabBarItem.image = UIImage(named: picArr[M])?.withRenderingMode(.alwaysOriginal)
                nav.tabBarItem.imageInsets = UIEdgeInsets(top: 16, left: 0, bottom: -16, right: 0);
                nav.tabBarItem.selectedImage = UIImage(named: picSelectArr[M])
                mainVC.title = nameArr[M]
                navVCArr.append(nav)
            }
            self.viewControllers = navVCArr as? [UIViewController]
    //        for  i in 0 ..< navVCArr.count {
    //            //设置导航栏的背景图片 （优先级高）
    //            (navVCArr[i] as AnyObject).navigationBar.setBackgroundImage(UIImage(named:"NavigationBar"), for:.default)
    //            //设置导航栏的背景颜色 （优先级低）
    //            (navVCArr[i] as AnyObject).navigationBar.barTintColor = UIColor.orange
    //            //设置导航栏的字体颜色
    ////            (navVCArr[i] as AnyObject).navigationBar.titleTextAttributes =
    ////                [NSForegroundColorAttributeName: UIColor.red]
    //
    //        }
                
        }}
